const zjzw = {
    state: {
        ticket: null,
        uiStyle: null,
    },
    mutations: {
        SET_TICKET: (state, ticket) => {
            // state.ticket = ticket
            setToken(ticket)
        },
        SET_UISTYLE: (state, style) => {
            if (!style) return state.uiStyle = 'default'
            state.uiStyle = style
        }
    },
    actions: {
        /* 单点登录 */
        ZWLogin ({ commit }, payload) {
            return new Promise((resolve, reject) => {
                postTicket(payload)
                    .then(res => {
                        if (res.data.code === 500) return reject(res.data.message)
                        if (res.data.data.indexOf('errmsg') > -1) return reject('票据已过期，请重新登录')
                        const response = res.data
                        commit('SET_TICKET', response.data)
                        resolve(response)
                    })
                    .catch(err => {
                        reject(err)
                    })
            })
        },
        /* 适老化 */
        SetUIStyle ({ commit }, payload) {
            commit('SET_UISTYLE', payload)
        }
    }
}

export default zjzw